<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Cadastro de Contatos</title>
    </h:head>
    <h:body>
        <h1>Cadastro de Contatos</h1>
        <h:form>
            <h:panelGrid columns="2">
                ID
                <h:inputText value="#{contatoMB.contato.id}"/>
                Nome
                <h:inputText value="#{contatoMB.contato.nome}"/>
                E-mail
                <h:inputText value="#{contatoMB.contato.email}"/>
                Nascimento
                <h:inputText value="#{contatoMB.contato.nascimento}">
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3"/>
                </h:inputText>                    
            </h:panelGrid>
            <h:commandLink action="#{contatoMB.novo()}">
                <h:graphicImage alt="novo" name="novo.png" library="imagens"/>
            </h:commandLink>       
            <h:commandLink action="#{contatoMB.gravar()}" onclick="return confirm('Deseja realmente salvar?')">
                <h:graphicImage alt="novo" name="salvar.png" library="imagens"/>
            </h:commandLink>       
            <h:commandLink action="#{contatoMB.pesquisar()}">
                <h:graphicImage alt="novo" name="pesquisar.png" library="imagens"/>
            </h:commandLink>
        </h:form>
        <br/>
        <br/>
        <h:form>
            <h:dataTable var="contatos" value="#{contatoMB.contatos}">
                <h:column>
                    <f:facet name="header">
                        <h:commandLink value="ID" action="#{contatoMB.ordenaID()}"/>
                    </f:facet>
                    #{contatos.id}                    
                </h:column>
                <h:column>
                    <f:facet name="header">
                        Nome
                        <h:commandLink value="+" action="#{contatoMB.ordenaNomeASC()}"/>
                        <h:commandLink value="-" action="#{contatoMB.ordenaNomeDESC()}"/>
                    </f:facet>
                    #{contatos.nome}                    
                </h:column>                
                <h:column>
                    <f:facet name="header">
                        <h:commandLink value="E-mail" action="#{contatoMB.ordenaEmail()}"/>
                    </f:facet>
                    #{contatos.email}                    
                </h:column>                
                <h:column>
                    <f:facet name="header">
                        Nascimento
                    </f:facet>
                    <h:outputText value="#{contatos.nascimento}">
                        <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3"/>
                    </h:outputText>
                </h:column>
                <h:column>
                    <f:facet name="header">                        
                    </f:facet>
                    <h:commandLink action="#{contatoMB.editar(contatos)}">
                        <h:graphicImage alt="editar" name="editar.png" library="imagens"/>
                    </h:commandLink>                                          
                </h:column>
                <h:column>
                    <f:facet name="header">                        
                    </f:facet>
                    <h:commandLink action="#{contatoMB.excluir(contatos)}" onclick="return confirm('Deseja realmente salvar?')">
                        <h:graphicImage alt="excluir" name="excluir.png" library="imagens"/>
                    </h:commandLink>                                          
                </h:column>
            </h:dataTable>
            <br/>
            <br/>
            <h:panelGrid columns="6">
                Filtar por ID
                <h:inputText value="#{contatoMB.idInicial}"/>
                a
                <h:inputText value="#{contatoMB.idFinal}"/>
                <h:commandButton value="Filtrar" action="#{contatoMB.filtraID()}"/>
                <h:commandButton value="Todos" action="#{contatoMB.listaTodos()}"/><br/>
                Filtar por Nascimento
                <h:inputText value="#{contatoMB.dataInicial}">
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3"/>
                </h:inputText>
                a
                <h:inputText value="#{contatoMB.dataFinal}">
                    <f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3"/>
                </h:inputText>            
                <h:commandButton value="Filtrar" action="#{contatoMB.filtraNascimento()}"/>
                <h:commandButton value="Todos" action="#{contatoMB.listaTodos()}"/>            
            </h:panelGrid>
        </h:form>
    </h:body>
</html>

